package com.example.milimili;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.text.method.ScrollingMovementMethod;
import android.view.View;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import java.util.HashMap;
import java.util.Map;

public class NewsActivity extends AppCompatActivity {

    private ImageButton backBtn,collectBtn;
    private TextView titleText,contentText;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_news);
        initView();
        Bundle bundle=getIntent().getExtras();
        SerializableMap sMap= (SerializableMap) bundle.getSerializable("map");
        Map<String,Object> dataMap=sMap.getMap();
        titleText.setText(dataMap.get("title").toString());
        contentText.setText(dataMap.get("content").toString());
        contentText.setMovementMethod(ScrollingMovementMethod.getInstance());
    }

    private void initView() {
        backBtn=findViewById(R.id.backButton);
        collectBtn=findViewById(R.id.collectButton);
        titleText=findViewById(R.id.title);
        contentText=findViewById(R.id.content);
        backBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent2=new Intent(NewsActivity.this,MainActivity.class);
                NewsActivity.this.startActivity(intent2);
            }
        });
        collectBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

            }
        });
    }

}